fix(deployments): keep the filters when you come back from a deployment - #561
Open
AbdullahM07 wants to merge 1 commit into
Open
fix(deployments): keep the filters when you come back from a deployment#561AbdullahM07 wants to merge 1 commit into
AbdullahM07 wants to merge 1 commit into
Conversation
Filter the deployments list by a project, open one of the rows, press Back — and the list returned showing every project again. Status and search did the same. The filters were component state only, and Back remounts the component, so each one reset to its default. A list you had deliberately narrowed silently became the full one, which is worse than losing the filter: the rows on screen looked like an answer to the question you had asked. They now live in the query string (`?status=`, `?project=`, `?q=`), so Back returns to the URL you left and the state comes back with it — the same URL-as-state approach the server detail page already uses for `?tab=`. Details worth knowing: - A filter at its default is absent from the URL, not `?status=all`, so an unfiltered visit leaves a clean address and never rewrites it. - The sync bails when the query string is already correct. That is the mount case, so restoring from a URL performs no navigation, and the effect cannot loop against its own dependency on searchParams. - `replace`, not `push`: filtering does not deserve history entries, and Back should leave the list, not step back through filter changes. `scroll: false` so re-filtering does not jump to the top. - An unrecognised status falls back to "all" rather than filtering against a value nothing matches, so a stale or hand-edited link cannot show an empty list. - Unrelated query params are preserved. Scoped to the standalone /deployments view. Embedded in a project the list is already that project's, the project selector is hidden, and that page owns its URL — it rewrites it to /projects/:id/:tab after reading its own params, which would strip anything written here and fight the sync. Tests mount the real component and drive the reported repro. Verified they catch the regression: with the change reverted, 5 of the 7 fail, including restoring the project filter. Adds happy-dom, needed to mount a component whose state depends on effects — the existing renderToStaticMarkup helpers run none. The row overflow menu is stubbed because it imports utils/icons, JSX inside a .js that the test transform cannot parse; the card itself stays real, since the card is what proves a filter was applied.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reported: on 0.6.5, go to Deployments → filter by one project → click a deployment → Back → the list shows all deployments again, no longer filtered.
What was wrong
The filters were component state only:
Back remounts the component, so all three reset to their defaults. Status and search were lost the same way as the project filter.
That's worse than just losing a filter: a list you had deliberately narrowed silently became the full one, and the rows on screen still looked like an answer to the question you'd asked.
The fix
The filters now live in the query string —
?status=,?project=,?q=— so Back returns to the URL you left and the state comes back with it. This is the same URL-as-state approach the server detail page already uses for?tab=.Details worth reviewing:
?status=all. An unfiltered visit leaves a clean address and never rewrites it.searchParams.replace, notpush. Filtering doesn't deserve history entries, and Back should leave the list rather than step back through every filter change.scroll: falseso re-filtering doesn't jump to the top.all, so a stale or hand-edited link can't wedge the view on a value nothing matches and show an empty list.DeploymentsFilters, so typing doesn't churn the URL.Scope
Deliberately limited to the standalone
/deploymentsview. Embedded in a project (isProject) the list is already that project's, the project selector is hidden, and that page owns its own URL — it rewrites to/projects/:id/:tabafter reading its params, which would strip anything written here and fight the sync.Testing
7 tests mount the real component and drive the reported repro: writing each filter to the URL, restoring each from the URL on mount (which is what Back does), dropping a param when it returns to its default, rejecting an invalid status, and preserving unrelated params.
Verified they catch the regression — with the change reverted, 5 of 7 fail, including restoring the project filter.
Two testing notes:
happy-dom. The dashboard had no DOM harness: every existing test usesrenderToStaticMarkup, which runs no effects and so can never reach state that depends on a fetch or a URL read. This overlaps with fix(dashboard): stop a bad payload from making a server undeletable #560, which adds the same devDependency — whichever merges second may need a trivial lockfile rebase.utils/icons, which is JSX inside a.jsfile that the test transform cannot parse (the monitoring suite documents the same constraint). The card itself stays real, since the card is what proves a filter was applied.